import 'package:FineArt/components/azlist/az_common.dart';
import 'package:FineArt/core/http/base_dio.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:retrofit/retrofit.dart';
import 'package:dio/dio.dart';
import '../../constants.dart';

part 'notice_api.g.dart';

@RestApi(baseUrl: kBaseUrl)
abstract class NoticeApi {
  factory NoticeApi({Dio dio, String baseUrl}) {
    dio ??= BaseDio.getInstance().getDio();
    return _NoticeApi(dio, baseUrl: baseUrl);
  }


  //获取通知列表
  @GET("/api/v1/sys-notices") //&pageSize=100&classId=1 这两可以没有id 为上次接受消息的最大ID
  Future<NoticeListResponse> getNoticeList(@Query("id") int id,
      @Query("pageSize") int pageSize);


  //提交建议
  @POST("/api/v1/sys-advices")
  Future<AdviceResponse> submitAdvices(@Body() AdvicesBodyReq body);
}
@JsonSerializable()
class AdvicesBodyReq {
  String title;
  String content;
  AdvicesBodyReq({this.title, this.content});
  Map<String, dynamic> toJson() => _$AdvicesBodyReqToJson(this);
}
@JsonSerializable()
class AdviceResponse {
  String requestId;
  String msg;
  int code;


  AdviceResponse({this.code, this.requestId,this.msg});

  factory AdviceResponse.fromJson(Map<String, dynamic> json) =>
      _$AdviceResponseFromJson(json);
}
////////////////
@JsonSerializable()
class NoticeListResponse {
  String requestId;
  String msg;
  int code;
  NoticeListData data;

  NoticeListResponse({this.code, this.data,this.requestId,this.msg});

  factory NoticeListResponse.fromJson(Map<String, dynamic> json) =>
      _$NoticeListResponseFromJson(json);
}
@JsonSerializable()
class NoticeListData {
  int pageSize;
  int pageIndex;
  int count;
  List<NoticeItemResp> list;

  NoticeListData({this.pageSize, this.count,this.pageIndex,this.list});

  factory NoticeListData.fromJson(Map<String, dynamic> json) =>
      _$NoticeListDataFromJson(json);
}

@JsonSerializable()
class NoticeItemResp {
  String content;
  String partnerId;
  String title;
  String link;
  String type;
  String invalidAt;
  String createdAt;
  String updatedAt;
  int id;
  int createBy;
  int updateBy;
  NoticeItemResp({this.content,this.title,this.id,this.link,this.type,
    this.createdAt,this.updatedAt,this.partnerId,this.invalidAt,this.createBy});

  factory NoticeItemResp.fromJson(Map<String, dynamic> json) =>
      _$NoticeItemRespFromJson(json);
}


///////////////
